package com.io;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class TestIo {

	public static void main(String[] args) throws Exception {
		List list = new ArrayList();
		list.add("");

		//		byte[] b = new byte[1024];

		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		DataOutputStream dos = new DataOutputStream(bos);
		dos.writeDouble(222.44);
		dos.writeUTF("ddddd");

		ByteArrayInputStream bai = new ByteArrayInputStream(bos.toByteArray());
		DataInputStream dis = new DataInputStream(bai);

		System.out.println(dis.readDouble());
		System.out.println(dis.readUTF());

		dos.close();
		dis.close();

		String str = null;
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		while (!"bye".equals(str = br.readLine())) {
			System.out.println(str);
			isr = new InputStreamReader(System.in);
		}
		br.close();
		System.out.println((9 + 3 - 1) / 3);
		System.out.println(6 / 4);

		System.out.println(6 % 2 == 0 ? (6 % 4 == 1 ? 6 / 2 : 6 / 2 + 1) : (6 / 2 == 0 ? 1 : 6 / 2));
		System.out.println(5 / 3 + 1);
	}

}
